<!doctype html>
<html lang="en">
<% include head.ejs %>
<title><%= essay.title %></title>
<link rel="stylesheet" href="/layui/css/home.css">
<link rel="stylesheet" href="/layui/css/details.css">
<body>
<header>
    <ul class="layui-nav" style="background:rgba(0, 0, 0, .8);">
        <div id="search">
            <form class="layui-form">
                <div class="layui-input-inline">
                    <input type="text" name="keyword" required  placeholder=""
                           autocomplete="off"
                           class="layui-input">
                    <button class="btn" lay-submit lay-filter="search"><i class="layui-icon layui-icon-search"></i>
                    </button>
                </div>
            </form>
        </div>
        <li class="layui-nav-item">
            <a href="">首页</a>
        </li>
        <li class="layui-nav-item">
            <a href="">About us</a>
        </li>
        <li class="layui-nav-item">
            <a href="">文章</a>
        </li>
        <% if(login) { %>
            <li class="layui-nav-item">
                <a id="user-pic" href="/user/<%= user.username %>">
                    <img src="/layui/images/1.jpg" class="layui-nav-img"><%= user.username %>
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="/user/<%= user.username %>">个人主页</a></dd>
                    <dd><a href="/admin/task/addtask">个人管理</a></dd>
                    <dd><a href="/logout">退出</a></dd>
                </dl>
            </li>
        <% }else{ %>
            <li class="layui-nav-item">
                <a href="/login">登录/注册</a>
            </li>
        <% } %>
    </ul>
</header>
<div id="page">
    <div class="essay">
        <div class="page-essay layui-anim layui-anim-up">
            <img class="essay-pic" src="" alt="">
            <div class="essay-class"><i class="layui-icon layui-icon-edit"></i></div>
            <div class="essay-dir"><h4><%= essay.dir %></h4></div>
            <div class="essay-title"><h5><%= essay.title %></h5></div>
            <div class="essay-uesr">
                <div class="essay-usernam"><i class="layui-icon layui-icon-friends"></i> <span><%= name %></span></div>
                &nbsp;&nbsp;&nbsp;
                <div class="essay-time"><i class="layui-icon layui-icon-date"></i> <span><%= new Date(essay.time).toLocaleString() %></span></div>
            </div>
            <div class="essay-content">
                <%- essay.content %>
            </div>
            <hr>
            <dl class="essay-report">
                <dd><i class="layui-icon layui-icon-star"> 收藏</i></dd>
                <dd><i class="layui-icon layui-icon-reply-fill"> 123</i></dd>
                <dd><i class="layui-icon layui-icon-share"> 233</i></dd>
                <dd><i class="layui-icon layui-icon-praise"> 3</i></dd>
            </dl>
        </div>

        <div class="page-essay-reply">
            <form class="layui-form">
                <textarea id="demo" style="display: none;"></textarea>
                <button class="layui-btn" lay-submit lay-filter="form"><i class="layui-icon layui-icon-release"></i> 回复
                </button>
                <dl class="essay-reply-list">
<!--                    <dd class="essay-reply-user">-->
<!--                        <img src="/layui/images/1.jpg" class="layui-nav-img">-->
<!--                        <div class="essay-reply">-->
<!--                            <div class="essay-reply-username">liuemmm</div>-->
<!--                            <div class="essay-reply-content">牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666</div>-->
<!--                            <div class="essay-reply-time">2019.12.25</div>-->
<!--                        </div>-->
<!--                    </dd>-->
<!--                    <dd class="essay-reply-user">-->
<!--                        <img src="/layui/images/1.jpg" class="layui-nav-img">-->
<!--                        <div class="essay-reply">-->
<!--                            <div class="essay-reply-username">刘阳</div>-->
<!--                            <div class="essay-reply-content">牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666牛逼666</div>-->
<!--                            <div class="essay-reply-time">2019.12.25</div>-->
<!--                        </div>-->
<!--                    </dd>-->
                </dl>
            </form>

        </div>
    </div>
</div>

<footer>
</footer>
<script>

    layui.use(['layedit', 'element', 'form'], function () {
        var layedit = layui.layedit;
        var element = layui.element;
        var form = layui.form;
        var edit = layedit.build('demo', {
            tool: ['face'],
            height: 100
        }); //建立编辑器
        form.on('submit(search)', function (data) {
            //layer.msg(JSON.stringify(data.field));
            window.location.href='/search?word='+data.field.keyword;
            return false;
        });
        form.on('submit(form)', (data) => {
            $('.essay-reply-list').prepend(`
                     <dd class="essay-reply-user">
                        <img src="/layui/images/1.jpg" class="layui-nav-img">
                        <div class="essay-reply">
                            <div class="essay-reply-username"><% user.username %></div>
                            <div class="essay-reply-content"><p>${layedit.getContent(edit)}</p></div>
                            <div class="essay-reply-time">${new Date().toLocaleString()}</div>
                        </div>
                    </dd>`);
            $('#LAY_layedit_1').contents().find('body').html('');
            return false;
        })
    });
</script>
</body>
</html>